package springapp.service;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

public class CreerDossierValidator implements Validator {

    /** Logger for this class and subclasses */
    protected final Log logger                 = LogFactory.getLog(getClass());

    public boolean supports(Class clazz) {
        return DossierCommand.class.equals(clazz);
    }	

    public void validate(Object obj, Errors errors) {
    	
    	ValidationUtils.rejectIfEmptyOrWhitespace(errors, "nom", "Dossier.NomInvalide", "Required field");
		
    	ValidationUtils.rejectIfEmptyOrWhitespace(errors, "prenom", "Dossier.PrenomInvalide", "Required field");
    	
    	ValidationUtils.rejectIfEmptyOrWhitespace(errors, "noPermis", "Dossier.NoPermisInvalide", "Required field");
		
    	ValidationUtils.rejectIfEmptyOrWhitespace(errors, "noPlaque", "Dossier.NoPlaqueInvalide", "Required field");
    	
    }
}